<?
function getSavePicPath()
{
	global $root;
	if (app_picpath == 1){
		$funresult = date('Y')."-".date("m");
	}
	elseif (app_picpath == 2){
		$funresult  = date('Y')."-".date("m")."-".date("d");
	}
	elseif (app_picpath == 3){
		for ($i=0; $i<50;$i++)
		{
			$path = date('Y')."-".date("m")."-".date("d") . "-".$i;
			$path1 = $_SESSION["upfolder"] . $path . "/";
			
			if (file_exists($path1)){
				$filecount= sizeof(scandir($path1));
				if($filecount>500){
					$funresult = date('Y')."-".date("m")."-".date("d") . "-". ($i+1);
				}
				else{
					$funresult = $path;
					break;
				}
			}
			else{
				$funresult = $path;
				break;
			}
		}
	}
	else{
		$funresult  = "";
	}
	return $funresult ;
}

function checkField($fieldName,$tableName)
{
	global $db;
	$dbarr = array();
	$rs = $db->query("SHOW COLUMNS FROM ".$tableName);
	while ($row = $db ->fetch_array($rs)){
		$dbarr[] = $row["Field"];
	}
	if(in_array($fieldName,$dbarr)){
		return true;
	}
	else {
		return false;
	}
}

function checkTable($tableName)
{
	global $db;
	$dbarr = array();
	$rs = $db->query("SHOW TABLES ");
	while ($row = $db ->fetch_array($rs)){
		$dbarr[] = $row["Tables_in_".app_dbname];
	}
	if(in_array($tableName,$dbarr)){
		return true;
	}
	else {
		return false;
	}
}

function cBreakpoint($fname)
{
	if (file_exists($fname.".html")) { return true ;} else { return false;}
}

function dBreakpoint($fname)
{
	if (file_exists($fname.".html"))  { unlink($fname.".html"); }
}

function wBreakpoint($fname,$url)
{
	$fdes = "<meta http-equiv=\"refresh\" content=\"0;url=".$url."\">";
	$ifile = new AppFile($fname.".html","w");
	$ifile->WriteFile($fdes,3); 
}
	
function gBreakpoint($fname)
{
	return file_get_contents($fname . ".html");
}
?>